package com.itboye.ihomebank.presenter;

import java.util.Observer;

import com.itboye.ihomebank.base.BasePresenter;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.interfaces.IRepairInterface;
import com.itboye.ihomebank.responsitory.RepairRepository;

/***
 * 维修
 * 
 * @author 递增给Responsitory
 * 
 */
public class RepairPersenter extends BasePresenter implements
		IRepairInterface<HouseBean> {

	// 申请维修
	public static final String shenQingWeiXiu_success = "_shenQingWeiXiu_success";
	public static final String shenQingWeiXiu_fail = "_shenQingWeiXiu_fail";
	
	// 查看维修信息
	public static final String weixiuXinxi_success = "_weixiuXinxi_success";
	public static final String weixiuXinxi_fail = "_weixiuXinxi_fail";
	
	// 查看维修状态
	public static final String weixiuZhuangTai_success = "_weixiuZhuangTai_success";
	public static final String weixiuZhuangTai_fail = "_weixiuZhuangTai_fail";
	
	// 查看维修状态
	public static final String yiDao_success = "_yiDao_success";
	public static final String yiDao_fail = "_yiDao_fail";
	
	// 维修结束
	public static final String theEnd_success = "_theEnd_success";
	public static final String theEnd_fail = "_theEnd_fail";
	
	// 维修结束并评价
	public static final String theEndAndPingJia_success = "_theEndAndPingJia_success";
	public static final String theEndAndPingJia_fail = "_theEndAndPingJia_fail";
	
	// 维修结束并评价
	public static final String biaoQian_success = "_biaoQian_success";
	public static final String biaoQian_fail = "_biaoQian_fail";

	public RepairPersenter(Observer observer) {
		super(observer);
	}
	/**
	 * 申请维修
	 */
	@Override
	public void shenQingWeiXiu(String uid,String image, String uname, String umobile,
			String repairId,String repairStatus, String ill, String address, String community,
			String status, String id) {
		// TODO Auto-generated method stub
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(shenQingWeiXiu_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(shenQingWeiXiu_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.shenQingWeiXiu(uid,image, uname, umobile,repairStatus, repairId, ill, address,
				community, status, id);

	}
	/**
	 * 查看维修信息(用来返回报修类型)
	 */
	@Override
	public void weiXiuXinXi(String status) {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(weixiuXinxi_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(weixiuXinxi_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.weiXiuXinXi(status);
		
	}
	/**
	 * 查看维修状态
	 */
	@Override
	public void chanKanWeiXiu(String uid, String status) {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(weixiuZhuangTai_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(weixiuZhuangTai_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.chanKanWeiXiu(uid,status);
		
	}
	/**
	 * 师傅已到
	 */
	@Override
	public void shiFuYiDao(String pid) {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(yiDao_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(yiDao_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.shiFuYiDao(pid);
		
	}
	/**
	 * 维修结束
	 */
	@Override
	public void xiuLiEnd(String pid) {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(theEnd_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(theEnd_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.xiuLiEnd(pid);
	}
	/**
	 * 维修结束并评价
	 */
	@Override
	public void xiuLiEndAndPingJia(String pid, int evaluate, String tags) {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(theEndAndPingJia_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(theEndAndPingJia_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.xiuLiEndAndPingJia(pid, evaluate, tags);
		
	}
	/**
	 * 查看师傅评价标签
	 */
	@Override
	public void biaoQian() {
		IRepairInterface<HouseBean> repair = new RepairRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(biaoQian_success);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(biaoQian_fail);
						RepairPersenter.this.setChanged();
						RepairPersenter.this.notifyObservers(result);

					}
				});
		repair.biaoQian();
		
	}

}
